package com.mall.pojo;

import com.mall.enums.CodeNum;
import com.mall.enums.CodeNumEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResponseMessage {
    private String statusCode;
    private String statusMessage;
    private Object content;

    public ResponseMessage(String statusCode, String statusMessage) {
        this.statusCode = statusCode;
        this.statusMessage = statusMessage;
    }

    public static ResponseMessage success(){
        ResponseMessage res = new ResponseMessage(CodeNumEntity.SUCCESS.getCode(),CodeNumEntity.SUCCESS.getMessage());
        return res;
    }

    public static ResponseMessage success(Object data){
        ResponseMessage res = new ResponseMessage(CodeNumEntity.SUCCESS.getCode(),CodeNumEntity.SUCCESS.getMessage());
        res.setContent(data);
        return res;
    }

    public static ResponseMessage failed(){
        ResponseMessage res = new ResponseMessage(CodeNumEntity.FAIL.getCode(),CodeNumEntity.FAIL.getMessage());
        return res;
    }

    public static ResponseMessage failed(Object data){
        ResponseMessage res = new ResponseMessage(CodeNumEntity.FAIL.getCode(),CodeNumEntity.FAIL.getMessage());
        res.setContent(data);
        return res;
    }

    /**
     * 自定义返回消息，不带数据
     */
    public static ResponseMessage custom(String statusCode, String statusMessage){
        return new ResponseMessage(statusCode,statusMessage);
    }

    /**
     * 自定义返回消息，带数据
     */
    public static ResponseMessage custom(String statusCode, String statusMessage,Object data){
        ResponseMessage res = new ResponseMessage(statusCode,statusMessage);
        res.setContent(data);
        return res;
    }
}
